var t = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("../../until/storage")), e = getApp(), a = null;

Page({
    data: {
        picArr: [ "http://www.120kg.xyz/static/images/wxMovie/gzh.jpeg", "http://www.120kg.xyz/static/images/wxMovie/id-card.jpeg", "http://www.120kg.xyz/static/images/wxMovie/zanshang.jpeg", "http://www.120kg.xyz/static/images/wxMovie/fls.jpeg" ],
        isRate: !1,
        videoSrc: "",
        dataUrl: "",
        isLive: !1,
        isFlsShow: !1,
        videoFrontAd: e.globalData.config.adConfig.liveVideoAd,
        videoAd: e.globalData.config.adConfig.videoAd,
        tabArr: [ {
            key: 1,
            value: "1.0x",
            select: 1,
            src: "movie",
            href: "1"
        }, {
            key: 2,
            value: "1.25x",
            select: 0,
            src: "tv",
            href: "1.25"
        }, {
            key: 3,
            value: "1.5x",
            select: 0,
            src: "cmc",
            href: "1.5"
        }, {
            key: 4,
            value: "2.0x",
            select: 0,
            src: "zy",
            href: "2"
        } ],
        currentTab: 0,
        index: 0,
        msgList: [],
        rateStatus: null,
        expires_timeOut: null
    },
    bannerNav: function(t) {
        var e = t.currentTarget.dataset.index;
        wx.previewImage({
            current: this.data.picArr[e],
            urls: this.data.picArr
        });
    },
    onShareAppMessage: function() {
        return {
            title: "[有人@你] 邀请您一起看免费[电影 | 电视剧]资源",
            path: "pages/index/index",
            imageUrl: "",
            success: function(t) {}
        };
    },
    showRate: function() {
        this.setData({
            isRate: !this.data.isRate
        });
    },
    _tab: function(e) {
        var i = e.currentTarget.dataset, o = i.key, n = i.index, s = i.href, r = t.default.get("localrateNum");
        if (this.data.currentTab === n) return !1;
        if (this.setData({
            currentTab: n,
            key: o,
            href: s,
            index: n,
            page: 1
        }), this.btnRate(s), this.data.rateStatus) if (r) {
            var c = r += 1;
            2 === r && (this.showToast("倍速广告每日只会出现一次哦!"), setTimeout(function() {
                a && a.show().catch(function() {
                    a.load().then(function() {
                        return a.show();
                    }).catch(function(t) {
                        console.log("激励视频 广告显示失败");
                    });
                });
            }, 2e3)), t.default.set("localrateNum", c);
        } else t.default.set("localrateNum", 1), wx.setStorageSync("localrateNum__expires__", Date.now() + 6e4 * this.data.expires_timeOut);
    },
    onLoad: function() {
        var t = this;
        this.setData({
            dataUrl: e.globalData.videoUrl || ""
        });
        var a = e.globalData.config, i = a.showVersion, o = a.sessionVersion;
        wx.request({
            url: "https://www.120kg.xyz/wxMovieVersion",
            success: function(e) {
                i < +e.data[o].version ? t.setData({
                    isLive: !0,
                    isFlsShow: e.data[o].isFlsShow,
                    msgList: e.data.tipMessage,
                    rateStatus: e.data[o].rateStatus,
                    expires_timeOut: +e.data[o].louckConfig.expires_timeOut || 1440
                }) : t.setData({
                    isLive: !1
                });
            }
        });
        var n = null;
        wx.createInterstitialAd && ((n = wx.createInterstitialAd({
            adUnitId: e.globalData.config.adConfig.liveInterstitialAd
        })).onLoad(function() {}), n.onError(function(t) {}), n.onClose(function() {})), 
        setTimeout(function() {
            n.show().catch(function(t) {
                console.error(t);
            });
        }, 9e3), this.setRewardedVideoAd();
    },
    onReady: function(t) {
        this.videoContext = wx.createVideoContext("myVideo");
    },
    btnRate: function(t) {
        var e = t;
        this.videoContext.playbackRate(Number(e));
    },
    goBack: function() {
        wx.navigateBackMiniProgram({
            success: function(t) {}
        });
    },
    goIndex: function() {
        wx.switchTab({
            url: "/pages/index/index"
        });
    },
    onShow: function() {},
    setRewardedVideoAd: function() {
        var i = this;
        wx.createRewardedVideoAd && ((a = wx.createRewardedVideoAd({
            adUnitId: e.globalData.config.adConfig.liveRewardedVideoAd
        })).onLoad(function() {}), a.onError(function(t) {}), a.onClose(function(e) {
            e && e.isEnded ? i.showToast("看完视频，可以使用倍速了") : (i.showToast("没有看完视频呀!"), t.default.set("localrateNum", 4));
        }));
    },
    showToast: function(t) {
        wx.showToast({
            title: t,
            icon: "none",
            duration: 3e3
        });
    }
});